fix(core): Preserve AI proxy property references#22474
Conversation
1445eaf to
e002cf1
Compare
e002cf1 to
8d957e5
Compare
8d957e5 to
681a0f6
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6f3a3a2. Configure here.
| return createDeepProxy(value, methodPath, options); | ||
| const nestedProxy = createDeepProxy(value, methodPath, options); | ||
| propertyCache.set(prop, { original: value, wrapped: nestedProxy }); | ||
| return nestedProxy; |
There was a problem hiding this comment.
Cache retains cleared SDK properties
Low Severity
The new propertyCache updates only when a property resolves to a wrapped function or object. If that property is later cleared or replaced with a non-object value, the get trap still returns the correct value but leaves the prior cache entry untouched, so nested proxies and their targets stay reachable for the life of the instrumented client.
Additional Locations (1)
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 6f3a3a2. Configure here.


AI integration deep proxies now reuse nested proxies and wrapped methods while the underlying property is unchanged. This makes repeated property access referentially stable for OpenAI and Google GenAI clients, while still refreshing a cached entry when an SDK property is replaced.
Anthropic is unchanged because the current
developimplementation instruments its methods in place and no longer uses this deep-proxy path.Root cause
Each
gettrap created a new nested proxy, instrumented wrapper, or bound function on every access. Caching functions alone would not cover repeated nested access because the intermediate proxies were also recreated.Focused regression coverage checks stable nested objects, instrumented methods, proxy-result methods, and non-instrumented bound methods.
Fixes #22355